﻿#include "widget.h"
#include "ui_widget.h"
#include <QMap>
#include <QMovie>

Widget::Widget(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::Widget)
{
    ui->setupUi(this);

    ui->label_text->setText("hello world");

    ui->label_html->setText("<h1><a href=\"https://www.baidu.com\">百度一下</a></h1>");
    ui->label_html->setOpenExternalLinks(true);

    connect(ui->pushButton_pic_mov, &QPushButton::clicked,this,&Widget::showPic_Mov);

}

Widget::~Widget()
{
    delete ui;
}

void Widget::showPic_Mov()
{
    if(ui->pushButton_pic_mov->text() == "图片")
    {
        QPixmap pixmap(":/new/Picture_Movie/2.png");       /* 创建一个QPixmap对象，实现图形数据类对象 */
        ui->label_picture->setPixmap(pixmap);
        ui->label_picture->setScaledContents(true);
        ui->pushButton_pic_mov->setText("动图");
    }
    else if(ui->pushButton_pic_mov->text() == "动图")
    {
        QMovie *movic = new QMovie(":/new/Picture_Movie/1.gif");
        ui->label_picture->setMovie(movic);
        ui->label_picture->setScaledContents(true);
        movic->start();
        ui->pushButton_pic_mov->setText("图片");
    }
}
